.TH std::ranges::sized_range,std::ranges::disable_sized_range 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::sized_range,std::ranges::disable_sized_range \- std::ranges::sized_range,std::ranges::disable_sized_range

.SH Synopsis
   Defined in header <ranges>
   template< class T >

   concept sized_range = ranges::range<T> &&
       requires(T& t) {                               \fB(1)\fP \fI(since C++20)\fP
           ranges::size(t);

       };
   template< class >                                  \fB(2)\fP \fI(since C++20)\fP
   inline constexpr bool disable_sized_range = false;

   1) The sized_range concept specifies the requirements of a range type that knows its
   size in constant time with the size function.
   2) disable_sized_range exists to allow use of range types that provide a size
   function (either as a member or as a non-member) but do not in fact model
   sized_range. Users may specialize disable_sized_range for cv-unqualified
   program-defined types. Such specializations shall be usable in constant expressions
   and have type const bool.

.SH Notes

   disable_sized_range cannot be used to opt-out a range whose iterator and sentinel
   satisfy sized_sentinel_for; std::disable_sized_sentinel_for must be used instead.

   disable_sized_range cannot be specialized for array types or reference types.

.SH Example


// Run this code

 #include <forward_list>
 #include <list>
 #include <ranges>

 static_assert
 (
     std::ranges::sized_range<std::list<int>> and
     not std::ranges::sized_range<std::forward_list<int>>
 );

 int main() {}

.SH See also

   ranges::random_access_range specifies a range whose iterator type satisfies
   (C++20)                     random_access_iterator
                               (concept)
   ranges::contiguous_range    specifies a range whose iterator type satisfies
   (C++20)                     contiguous_iterator
                               (concept)
